﻿<Window x:Class="GEPL.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:GEPL.Properties"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:views="clr-namespace:GEPL.Views"
        xmlns:vm="clr-namespace:GEPL.ViewModels"
        xmlns:converters="clr-namespace:GEPL.Converters"
        xmlns:extensions="clr-namespace:GEPL.Extensions"
        xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
        Title="{x:Static p:Resources.MainWindow_Title}"
        Height="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Height, Mode=TwoWay}"
        Width="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Width, Mode=TwoWay}"
        WindowState="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_State, Mode=TwoWay}"
        Left="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Left, Mode=TwoWay}"
        Top="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Top, Mode=TwoWay}"
        Closing="Window_Closing" d:DataContext="{d:DesignInstance vm:MainWindowViewModel}">
    <Window.Resources>
        <converters:NullToBooleanConverter x:Key="NullToBooleanConverter" />
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Style x:Key="GridSplitterPreviewStyle">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Fill="#80000000" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="GridSplitterStyle1" TargetType="{x:Type GridSplitter}">
            <Setter Property="Background"
                Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
            <Setter Property="PreviewStyle" Value="{StaticResource GridSplitterPreviewStyle}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GridSplitter}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            CornerRadius="5">
                            <Canvas RenderOptions.EdgeMode="Aliased" UseLayoutRounding="True"
                                Height="6" VerticalAlignment="Center"
                                Width="50" HorizontalAlignment="Center">
                                <Line X1="0" X2="50" Y1="0" Y2="0"
                                  Stroke="White" StrokeThickness="1" />
                                <Line X1="0" X2="50" Y1="1" Y2="1"
                                  Stroke="#A0A0A0" StrokeThickness="1" />
                                <Line X1="0" X2="50" Y1="4" Y2="4"
                                  Stroke="White" StrokeThickness="1" />
                                <Line X1="0" X2="50" Y1="5" Y2="5"
                                  Stroke="#A0A0A0" StrokeThickness="1" />
                            </Canvas>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="N" Modifiers="Control" Command="{Binding NewConsoleProjectCommand}" />
        <KeyBinding Key="T" Modifiers="Control" Command="{Binding NewTurtleProjectCommand}" />
        <KeyBinding Key="O" Modifiers="Control" Command="{Binding OpenProjectCommand}" />
        <KeyBinding Key="S" Modifiers="Control" Command="{Binding SaveAsCommand}" />
        <KeyBinding Key="F5" Command="{Binding ExecuteCommand}" />
        <KeyBinding Key="F1" Command="{Binding ShowHelpCommand}" />
    </Window.InputBindings>
    <DockPanel LastChildFill="True">
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="{x:Static p:Resources.Menu_File}">
                <MenuItem Header="{x:Static p:Resources.Menu_File_NewProject}">
                    <MenuItem Header="{x:Static p:Resources.Menu_File_NewProject_Console}"
                              Command="{Binding NewConsoleProjectCommand}"
                              InputGestureText="Ctrl + N" />
                    <MenuItem Header="{x:Static p:Resources.Menu_File_NewProject_Turtle}"
                              Command="{Binding NewTurtleProjectCommand}"
                              InputGestureText="Ctrl + T" />
                </MenuItem>
                <MenuItem Header="{x:Static p:Resources.Menu_OpenProject}"
                          Command="{Binding OpenProjectCommand}"
                          InputGestureText="Ctrl + O" />
                <MenuItem Header="{x:Static p:Resources.Menu_SaveAs}"
                          Command="{Binding SaveAsCommand}"
                          InputGestureText="Ctrl + S" />
                <MenuItem Header="{x:Static p:Resources.Menu_SaveResultAs}"
                          Command="{Binding SaveOutputCommand}" />
                <MenuItem Header="{x:Static p:Resources.Menu_CloseProject}"
                          Command="{Binding CloseProjectCommand}" />
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.Menu_Execute}"
                      Command="{Binding ExecuteCommand}" />
            <MenuItem Header="{x:Static p:Resources.Menu_ShowCode}"
                      Command="{Binding ShowCodeCommand}"
                      Visibility="{Binding Source={x:Static p:Settings.Default}, Path=Settings_ExpertMode, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <MenuItem Header="{x:Static p:Resources.Menu_Settings}">
                <MenuItem Header="{x:Static p:Resources.Menu_Language}">
                    <MenuItem Header="{x:Static p:Resources.Menu_Language_Auto}"
                              IsCheckable="True"
                              IsChecked="{Binding AutoLangChecked}"
                              Command="{Binding ChangeLanguageCommand}"
                              extensions:MenuItemExtensions.GroupName="LanguageSelection" />
                    <MenuItem Header="{x:Static p:Resources.Menu_Language_English}"
                              IsCheckable="True"
                              IsChecked="{Binding EnLangChecked}"
                              Command="{Binding ChangeLanguageCommand}"
                              extensions:MenuItemExtensions.GroupName="LanguageSelection" />
                    <MenuItem Header="{x:Static p:Resources.Menu_Language_Polish}"
                              IsCheckable="True"
                              IsChecked="{Binding PlLangChecked}"
                              Command="{Binding ChangeLanguageCommand}"
                              extensions:MenuItemExtensions.GroupName="LanguageSelection" />
                </MenuItem>
                <MenuItem Header="{x:Static p:Resources.Menu_Settings_ClearScopeBeforeExecution}"
                          IsCheckable="True"
                          IsChecked="{Binding Source={x:Static p:Settings.Default}, Path=Settings_ClearScope, Mode=TwoWay}"
                          Visibility="{Binding Source={x:Static p:Settings.Default}, Path=Settings_ExpertMode, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}" />
                <MenuItem Header="{x:Static p:Resources.Menu_ExpertMode}"
                          IsCheckable="True"
                          IsChecked="{Binding Source={x:Static p:Settings.Default}, Path=Settings_ExpertMode, Mode=TwoWay}"
                          Command="{Binding ExpertModeCommand}" />
            </MenuItem>
            <MenuItem Header="{x:Static p:Resources.Menu_Help}"
                      Command="{Binding ShowHelpCommand}" />
            <MenuItem Header="{x:Static p:Resources.Menu_About}"
                      Command="{Binding ShowAboutCommand}" />
        </Menu>
        <DockPanel DockPanel.Dock="Left"
                   LastChildFill="True">
            <StatusBar DockPanel.Dock="Top"
                       Background="#FFE6E6E6"
                       Height="30"
                       Padding="5,0,0,0">
                <TextBlock Text="{x:Static p:Resources.Toolbox}" />
            </StatusBar>
            <ListView x:Name="ToolboxListView"
                  Width="200"
                  ItemsSource="{Binding ToolboxElementsList}"
                  dd:DragDrop.IsDragSource="True"
                  Background="#FFE6E6E6"
                  BorderThickness="0"
                  SelectionMode="Single">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding ElementName}"
                               FontSize="16"
                               FontFamily="Segoe UI Semibold"
                               Padding="5" />
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </DockPanel>
        <Grid x:Name="MainGrid"
              IsEnabled="{Binding WorkspaceViewModel.Project, Mode=OneWay, Converter={StaticResource NullToBooleanConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <views:Workspace DataContext="{Binding WorkspaceViewModel}"
                             Grid.Column="0"
                             Grid.Row="0" />
            <GridSplitter Grid.Row="1"
                          Height="16"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Stretch"
                          BorderBrush="White"
                          BorderThickness="1"
                          Style="{StaticResource GridSplitterStyle1}">
                <GridSplitter.Background>
                    <LinearGradientBrush EndPoint="0.5,0"
                                         StartPoint="0.5,1">
                        <GradientStop Color="#A0A0A0"
                                      Offset="0" />
                        <GradientStop Color="#E5E5E5"
                                      Offset="0.15" />
                        <GradientStop Color="#ECECEC"
                                      Offset="0.8" />
                        <GradientStop Color="#E5E5E5"
                                      Offset="1" />
                    </LinearGradientBrush>
                </GridSplitter.Background>
            </GridSplitter>
        </Grid>
    </DockPanel>
</Window>